<p>Swift lets us use functions just like any other type such as strings and integers. This means you can create a function and assign it to a variable, call that function using that variable, and even pass that function into other functions as parameters.</p>
<p>Functions used in this way are called <em>closures</em>, and although they work like functions they are written a little differently.</p>
<p>Let’s start with a simple example that prints a message:</p>
<pre class="code">
<p></p>
<p><span class="keyword">let</span> driving <span class="operator">=</span> <span class="punctuation">{</span></p>
<p>  <span class="function">print</span><span class="punctuation">(</span><span class="string">"I'm driving in my car"</span><span class="punctuation">)</span></p>
<p><span class="punctuation">}</span></p>
<p></p>
</pre>

<p style="height: 0px; margin-bottom: 0px;"></p>
<p>That effectively creates a function without a name, and assigns that function to <code>driving</code>. You can now call <code>driving()</code> as if it were a regular function, like this:</p>
<pre class="code">
<p></p>
<p><span class="function">driving</span><span class="punctuation">(</span><span class="punctuation">)</span></p>
<p></p>
</pre>

<p style="height: 0px; margin-bottom: 0px;"></p>